<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import OrderEvent from "@/mixin/orderEvent";

export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Table,
    OrderEvent,
  ],
  computed: {},
  data() {
    return {
      load: false,
      item: null,
      title: "订单详情",

      // 订单详情数据
      orderData: "",

      // 窗口显示
      boxVisible: false,
    };
  },
  methods: {
    // 关闭窗口
    editBoxClose() {
      this.boxVisible = false;
    },
    // 取消
    editBoxCancel() {
      this.editBoxClose();
    },

    // 处理table表格最后一行数据
    getSummaries(param) {
      // console.error(param);
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "总计(不含抵扣及税费)";
          return;
        }

        if (column.property === "totalAmount") {
          const values = data.map((item) => Number(item["totalAmount"]));

          let total = values.reduce(
            (totalPrice, price) => totalPrice + price,
            0
          );

          sums[index] = `${total}元`;
        }
      });

      return sums;
    },

    // 发票类型转文字
    invoiceType2Text(num) {
      let text;
      switch (num) {
        case 1:
          text = "普通发票";
          break;
        case 2:
          text = "电子普通发票";
          break;
        case 3:
          text = "增值税专用发票";
          break;
        default:
          text = "无";
      }
      return text;
    },
  },
  watch: {},
  async mounted() {
    if (this.item) {
      this.orderData = this.item;

      console.log(this.orderData);
    }

    this.boxVisible = true;
  },
  beforeCreate() {},
};
</script>